﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using HPT.Utilities;

namespace HPT
{
    public class PresenterNewsDetails
    {
        private IViewNewsDetails view;

        public PresenterNewsDetails(IViewNewsDetails view)
        {
            // TODO: Complete member initialization
            this.view = view;
        }
        //Get all news
        public void GetNewsById()
        {
            SPList listNews = OWeb.GetList(Constants.List.News);
            if (view.ID != 0)
            {
                SPListItem newsResult = listNews.GetItemById(view.ID);
                //if (String.IsNullOrEmpty(OConvert.ToString(newsResult["HitCounter"])))
                //    newsResult["HitCounter"] = 1;
                //else
                newsResult["HitCounter"] = OConvert.ToInt(newsResult["HitCounter"]) + 1;
                newsResult.Update();
                NewsModal getNews = new NewsModal(newsResult);
                view.News = getNews;
            }
            else
                view.News = null;    
        }
    }
}
